<include file="Public:header" />
<div class="container">
	<div class="page-header">
		<h4>{:L('ADD_CONTACT')}</h4>
	</div>
	<div class="row">
		<div class="span12">
			<include file="Public:alert" />
			<form action="{:U('contacts/add')}" method="post">
				<input type="hidden" name="redirect" value="{$redirect}"/>
				<input type="hidden" name="redirect_id" value="{$redirect_id}"/>  
				<input type='hidden' name="r" <present name="r">value="{$r}"</present>/>
				<input type='hidden' name="module" <present name="r">value="{$module}"</present>/> 
				<input type='hidden' name="id" <present name="r">value="{$model_id}"</present>/> 
				<table class="table" width="95%" border="0" cellspacing="1" cellpadding="0">
					<thead>
						<tr>
							<td>&nbsp;</td>
							<td <if condition="C('ismobile') neq 1">colspan="3"</if>><input name="submit" class="btn btn-primary" type="submit" value="{:L('SAVE')}"/>&nbsp; <input name="submit" class="btn btn-primary" type="submit" value="{:L('SAVE AND NEW')}"/> &nbsp;<input class="btn" type="button" onclick="javascript:history.go(-1)" value="{:L('RETURN')}"/></td>
						</tr>
					</thead>
					<tfoot>
						<tr> 
							<td>&nbsp;</td>
							<td <if condition="C('ismobile') neq 1">colspan="3"</if>><input name="submit" class="btn btn-primary" type="submit" value="{:L('SAVE')}"/> &nbsp;<input name="submit" class="btn btn-primary" type="submit" value="{:L('SAVE AND NEW')}"/>&nbsp; <input class="btn" type="button" onclick="javascript:history.go(-1)" value="{:L('RETURN')}"/> </td>				
						</tr>
					</tfoot>
					<tbody>
						<tr><th <if condition="C('ismobile') eq 1">colspan="2"<else />colspan="4"</if>>{:L('BASIC_INFO')}</th></tr>
						<tr>
							<td class="tdleft" width="15%">{:L('NAME')}</td>
							<td width="35%" ><input class="text-input large-input" type="text" name="name" id="name"></td>
							<if condition="C('ismobile') eq 1"></tr><tr></if>
							<td class="tdleft" width="15%">{:L('RESPECTFULLY')}</td>
							<td width="35%" >
								<select name="saltname" class="span2">
									<option value="">-{:L('NO')}-</option>
									<option value="{:L('SIR')}">{:L('SIR')}</option>
									<option value="{:L('LADY')}">{:L('LADY')}</option>
									<option value="{:L('TEACHER')}">{:L('TEACHER')}</option>
									<option value="{:L('DOCTOR')}">{:L('DOCTOR')}</option>
									<option value="{:L('DOCTORS')}">{:L('DOCTORS')}</option>
									<option value="{:L('PROFESSOR')}">{:L('PROFESSOR')}</option>
								</select>
							</td>
						</tr>
						<tr>
							<td class="tdleft" >{:L('BELONGS_TO_THE_CUSTOMER_CLICK_TO_SELECT')}</td>
							<td><input type="hidden" name="customer_id" id="customer_id" value="{$customer['customer_id']}"/><input type="text" name="customer_name" id="customer_name"value="{$customer.name}"/></td>
							<if condition="C('ismobile') eq 1"></tr><tr></if>
							<td class="tdleft" >{:L('POSITION')}</td>
							<td>
								<input class="text-input large-input"  type="text" name="post"/>
							</td>
						</tr>
						<tr>
							<td class="tdleft" >{:L('PHONE')}</td>
							<td><input class="text-input large-input" name="telephone" type="text" /></td>
							<if condition="C('ismobile') eq 1"></tr><tr></if>
							<td class="tdleft" >{:L('EMAIL')}</td>
							<td><input class="text-input large-input" name="email" type="text" /></td>
						</tr>
						<tr>
							<td class="tdleft" >QQ</td>
							<td><input class="text-input large-input" name="qq" type="text" /></td>
							<if condition="C('ismobile') eq 1"></tr><tr></if>
							<td class="tdleft" >{:L('POSTCODE')}</td>
							<td><input class="text-input large-input" name="zip_code" type="text"/></td>
						</tr>
						<tr>
							<td class="tdleft" >{:L('CONTACT_ADDRESS')}</td>
							<td><input class="text-input large-input" name="address" type="text"/></td>
						</tr>
						<tr>
							<td class="tdleft" >{:L('REMARK')}</td>
							<td <if condition="C('ismobile') neq 1">colspan="3"</if>><textarea rows="6" class="span8" name="description" ></textarea></td>
						</tr>
					</tbody>
				</table>
			</form>			
		</div>
	</div>
</div>
<div id="dialog-message2" title="{:L('SELECT_THE_CONTACT_BELONGS_TO_THE_CUSTOMER')}">loading...</div>
<script type="text/javascript">
<if condition="C('ismobile') eq 1">width=$('.container').width() * 0.9;<else/>width=800;</if>
$("#dialog-message2").dialog({
	autoOpen: false,
	modal: true,
	width: width,
	maxHeight: 400,
	buttons: {
		"{:L('AFFIRM')}": function () {
			var item = $('input:radio[name="customer"]:checked').val();
			var name = $('input:radio[name="customer"]:checked').parent().next().html();
			if(item){
				$('#customer_name').val(name);
				$('#customer_id').val(item);
			}
			$(this).dialog("close");
		},
		"{:L('CANCEL')}": function () {
			$(this).dialog("close");
		}
	},
	position: ["center", 100]
});

$(function(){
	$("#customer_name").click(
		function(){
			$('#dialog-message2').dialog('open');
			$('#dialog-message2').load('{:U("customer/listDialog")}');
		}
	);
	
});
</script>
<include file="Public:footer" />